package com.ppc.ugo.controller;

import com.ppc.ugo.common.cache.Cache;
import com.ppc.ugo.common.log.LogAnnotation;
import com.ppc.ugo.service.GoodService;
import com.ppc.ugo.vo.Result;
import com.ppc.ugo.vo.param.GoodParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/public/v1/goods")
public class GoodController {
    @Autowired
    private GoodService goodService;

    @GetMapping("qsearch")
    @LogAnnotation(module = "商品", operation = "获取搜索建议列表")
    @Cache(name = "qsearch", expire = 5 * 60 * 1000)
    public Result qSearch(String query){
        return goodService.qSearch(query);
    }

    @GetMapping("search")
    @Cache(name = "search", expire = 5 * 60 * 1000)
    @LogAnnotation(module = "商品", operation = "获取商品列表")
    public Result search(GoodParam goodParam){
        return goodService.search(goodParam);
    }

    @GetMapping("detail")
    @Cache(name = "detail", expire = 5 * 60 * 1000)
    @LogAnnotation(module = "商品", operation = "获取商品详细信息")
    public Result detail(String goods_id){
        return goodService.detail(goods_id);
    }

}
